package com.heima.search.controller;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.model.search.vos.SearchArticleVo;
import com.heima.search.service.ArticleSearchService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/v1")
public class ArticleSearchController {

    @Resource
    private ArticleSearchService articleSearchService;


    @PostMapping("/article/search/search")
    public ResponseResult<List<SearchArticleVo>> search(@RequestBody UserSearchDto dto) throws IOException {
        return articleSearchService.search(dto);
    }

    @PostMapping("assoicate/search")
    public ResponseResult<List<String>> autoCompletion(@RequestBody UserSearchDto userSearchDto) {
        return this.articleSearchService.autoCompletion(userSearchDto);
    }
}
